import {BasicColumn, FormSchema} from '/@/components/Table';
import {commonStatusDict, commonStatusDictMap} from '/@/utils/dict';

export const columns: BasicColumn[] = [
  {
    title: '应用ID',
    dataIndex: 'appId',
  },
  {
    title: '应用名称',
    dataIndex: 'appName',
  },
  {
    title: '商户号',
    dataIndex: 'mchNo',
  },
  {
    title: '状态',
    dataIndex: 'status',
    dictFormat: commonStatusDictMap,
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'appId',
    label: '应用ID',
    component: 'Input',
    colProps: {span: 6},
  },
  {
    field: 'appName',
    label: '应用名称',
    component: 'Input',
    colProps: {span: 6},
  },
  {
    field: 'mchNo',
    label: '商户号',
    component: 'Input',
    colProps: {span: 6},
  },
  {
    field: 'status',
    label: '状态',
    component: 'Select',
    componentProps: {
      options: commonStatusDict,
    },
    colProps: {span: 6},
  },
];

export const formSchema: FormSchema[] = [
  {
    field: 'id',
    label: 'ID',
    component: 'Input',
    show: false,
  },
  {
    field: 'appId',
    label: '应用ID',
    component: 'Input',
    dynamicDisabled: ({values}) => {
      return !!values.id;
    },
    ifShow: ({values}) => !!values.id,
  },
  {
    field: 'mchNo',
    label: '商户号',
    component: 'Input',
    dynamicDisabled: ({values}) => {
      return !!values.id;
    },
    required: true,
  },
  {
    field: 'appName',
    label: '应用名称',
    component: 'Input',
    required: true,
  },
  {
    field: 'status',
    label: '状态',
    component: 'RadioGroup',
    defaultValue: 1,
    componentProps: {
      options: commonStatusDict,
    },
    required: true,
  },
  {
    field: 'appSecret',
    label: '应用私钥',
    component: 'InputTextArea',
    componentProps: {
      placeholder: '应用私钥',
    },
    colProps: {lg: 24, md: 24},
    required: true,
  },
  {
    field: 'remark',
    label: '备注',
    component: 'InputTextArea',
    componentProps: {
      placeholder: '备注',
    },
    colProps: {lg: 24, md: 24},
  },
];
